//============================================================================
// Name        : cpp_application_path.cpp
// Author      : darkflash
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <iostream>

#ifdef WINDOWS
   #include <windows.h>
#else
    #include <unistd.h>
	#include <limits.h>
 #endif

using namespace std;

namespace fs = boost::filesystem;

string getexepath(){
	char result[ PATH_MAX ];

#ifdef WINDOWS
	return std::string( result, GetModuleFileName( NULL, result, MAX_PATH ) );
#else
	ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX );
	return std::string( result, (count > 0) ? count : 0 );
#endif
}

int main(int argc, char* argv[]) {
		fs::path work_path( fs::initial_path<fs::path>() );

	    //fs::path application_path = fs::system_complete( fs::path( argv[0] ) );
		fs::path application_path = (work_path / argv[0]).parent_path();

		cout << "==========> application path" << endl;
	    cout << application_path.string() << endl;

	    cout << "==========> work path" << endl;
	    cout << work_path.string() << endl;

	return 0;
}
